package com.example.wei.mvp.ui.dialog;

import android.app.Activity;
import android.app.Dialog;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.example.wei.mvp.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;



/**
 * Created by win7 on 2017/7/24.
 */

public class OneButtonDialog extends Dialog {


    @BindView(R.id.tv_content)
    TextView tvContent;
    @BindView(R.id.tv_sure)
    TextView tvSure;
    @BindView(R.id.tv_title)
    TextView tvTitle;
    private OnOneButtonClickListener oneButtonClickListener;
    private String button;
    private String content;
    private String title;
    private Activity activity;

    public OneButtonDialog(Activity activity,String title, String content, String button) {
        super(activity, R.style.MyDialogStyleTop);
        this.activity = activity;
        this.button = button;
        this.content = content;
        this.title = title;
        initView();
    }

    private void initView() {
        View view = LayoutInflater.from(getContext()).inflate(R.layout.dialog_custom_one, null);
        ButterKnife.bind(this,view);
        tvTitle.setText(title);
        tvContent.setText(content);
        tvSure.setText(button);
        show();
        setContentView(view);
        setCancelable(false);
        setCanceledOnTouchOutside(false);
    }

    @OnClick(R.id.tv_sure)
    public void onViewClicked() {
        if (oneButtonClickListener!=null){
            oneButtonClickListener.onOneButtonClick();
        }
        dismiss();
    }

    public interface OnOneButtonClickListener {

        void onOneButtonClick();

    }

    public void setOnOneButtonClickListener(OnOneButtonClickListener oneButtonClickListener) {

        this.oneButtonClickListener = oneButtonClickListener;

    }

}
